/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: ws
 * Date: 2022-12-03
 * Time: 18:31
 */
public class Test {
    public int Sum(int[]... arr) {
        int sum = 0;
        for (int i = 0; i < arr.length; i++) {
            for (int j = 0; j < arr[i].length; j++) {
                sum += arr[i][j];
            }
        }
        return sum;
    }


    //    public void Sum( int x, int... arr1, double... arr2) {
//        //报错
//    }
    public void Sum(int x, int[] arr1, double... arr2) {
        //正确
    }

    public static void main(String[] args) {
        Test test = new Test();
        int[] arr1 = new int[]{1};
        int[] arr2 = new int[]{1 ,2};
        int[] arr3 = new int[]{1, 2, 3};
        int[] arr4 = new int[]{1, 2, 3, 4};

        int a = test.Sum(new int[]{},arr1, arr2,arr3,arr4);//也可以直接new个数组
        System.out.println(a);//20
    }
}
